#ifndef __BALLOON_H__
#define __BALLOON_H__
#include "GameObject.h"
#include "vector2d.h"
#include "Timer.h"


class ASprite;

enum Ball_State
{
		BALL_STATE_IDLE = -1,
		BALL_STATE_CURVE,
		BALL_STATE_MOVING,
		BALL_STATE_BACK,
};
class Item;

enum BALL_NATURE
{
	RED_NATURE = 1,
	GREEN_NATURE = 1<<1,
	BLUE_NATURE = 1<<2,
	CYAN_NATURE = (RED_NATURE | BLUE_NATURE),
	MAGENTA_NATURE = (GREEN_NATURE | BLUE_NATURE),
	YELLOW_NATURE = (RED_NATURE | GREEN_NATURE),
};

class ParticleHolder;
class Balloon :public GameObject
{
public:
	
	Balloon();


	
public:
	ASprite* m_sprite;

	float m_beginPointX;
	float m_beginPointY;
	float m_controlPointX;
	float m_controlPointY;
	float m_targetPointX;
	float m_targetPointY;	
	float m_stepBenzier;
	vector2df m_lastSpeed;
	vector2df m_Speed;
	vector2df m_displacement;
	vector2df m_lastCollisionPoint;
	vector2df m_closestPoint;
	int m_state;
	bool m_bIsMovementEnabled;

	int m_radius;
	unsigned int m_color;
	//int m_curLifeTime;
	//int m_maxLifeTime;
	Item* m_refItem;
	//bool m_bBackInNextStep;
	int m_damage;

	Timer		m_lifeTimer;
	int		m_rebounds;
	int		m_bounceCount;

	void  SetState(int state) {m_state = state;}
	int GetState(){return m_state;} 

	int m_nature;

	ParticleHolder* m_electricEffect;
public:
	virtual void Load(IAttributes* attr);
	virtual void Draw();
	virtual void Update();
	virtual void Initialize();
	virtual void InitPhysics();
	virtual void   SetEnabled(bool v);
	virtual void SaveData(CWriteFile* stream);
	virtual void LoadData(CReadFile* stream);

	virtual bool ShouldCollideWith( GameObject* h );
	virtual void Update_PreCollision();
	virtual void Update_PostCollision();

	bool		CanMove() const {return m_bIsMovementEnabled;}
	void		EnableMovement() { m_bIsMovementEnabled = true; }
	void		DisableMovement() { m_bIsMovementEnabled = false; SetNoDisplacement();}
	void		SetNoDisplacement();

	float		GetSpeed(){return 9.0f;}

	void SetNature(int nature);

	void InitEffect();
	inline int GetNature() {return m_nature;}

	virtual void CompDisplacement();

	void SetPath(float cx,float cy, float ex, float ey);
	void setColor(unsigned int color){m_color = color;}
	inline void setRefItem(Item* item){m_refItem = item;}

};
#endif